package nio.base;

import java.nio.Buffer;
import java.nio.ByteBuffer;
/**
 * @author cyt
 * @create 2020-10-19 16:45
 */
public class BufferDemo {

    public static void main(String[] args) throws Exception {
        String str = "buffer";
        byte[] bytes = str.getBytes();
        ByteBuffer wrap = ByteBuffer.wrap(bytes);
        wrap.put(new Byte("d"));

        byte b = wrap.get(2);
        System.out.println(b);

        Buffer mark = wrap.mark();

        Buffer reset = wrap.reset();

        Buffer flip = wrap.flip();

        Buffer rewind = wrap.rewind();

        Buffer clear = wrap.clear();

        ByteBuffer compact = wrap.compact();

//        FileInputStream inputStream = new FileInputStream(new File("E:/资料/note/note/STL.md"));
//        FileChannel channel = inputStream.getChannel();
//        int read = channel.read(wrap);
//        System.out.println(read);
    }
}
